<?php
$res = FDB::query('SELECT uid FROM '.FDB::table('user_follow').'  WHERE f_uid = '.$home_uid.' ORDER BY create_time DESC LIMIT 4');
$uids = array();
while($data = FDB::fetch($res)) {
    $uids[] = $data['uid'];
}
if(!empty($uids)) {
    $res = FDB::query('SELECT uid,user_name,avatar FROM '.FDB::table('user').' WHERE uid IN('.implode(',', $uids).')');
    while($data = FDB::fetch($res)) {
    	if($home_uid == $_FANWE['uid'])
    		$data['is_follow'] = FS('User')->getIsFollowUId2($data['uid'],$home_uid);
    
    	if($home_uid != $_FANWE['uid'])
    		$data['is_follow'] = FS('User')->getIsFollowUId($data['uid']);
        $myfollow_list[] = $data;
    }
}

$res = FDB::query('SELECT uid FROM '.FDB::table('user_follow').'  WHERE uid = '.$home_uid.' ORDER BY create_time DESC LIMIT 4');
$uids = array();
while($data = FDB::fetch($res)) {
    $uids[] = $data['uid'];
}
if(!empty($uids)) {
    $res = FDB::query('SELECT uid,user_name,avatar FROM '.FDB::table('user').' WHERE uid IN('.implode(',', $uids).')');
    while($data = FDB::fetch($res)) {
    	if($home_uid == $_FANWE['uid'])
    		$data['is_follow'] = FS('User')->getIsFollowUId2($data['uid'],$home_uid);
    
    	if($home_uid != $_FANWE['uid'])
    		$data['is_follow'] = FS('User')->getIsFollowUId($data['uid']);
        $myfan_list[] = $data;
    }
}

?>

<div class="user_rightbox">
    <div class="i_tt">
        <h3>关注/粉丝</h3>
        <p>我的关注和粉丝</p>
    </div>
    <div class="i_warp">
        <fieldset class="i_ttmore">
            <legend><a href="{u u/follow uid=$home_uid}">我的关注({$home_user['follows']})</a></legend>
            <div class="j_more"><a href="{u u/follow uid=$home_uid}">更多»</a></div>
        </fieldset>
        <div class="i_funs">
            <ul>
                <!--{loop $myfollow_list $v}-->
                <li>
                    <a href="{u u/index uid=$v['uid']}" class="a1"><img src="{avatar $v['avatar'] m}" /></a>
                    <a href="{u u/index uid=$v['uid']}" class="a2">{$v['user_name']}</a>
                </li>
                <!--{/loop}-->
            </ul>
            <div class="g_clear"></div>
        </div>
        <fieldset class="i_ttmore">
            <legend><a href="{u u/fans uid=$home_uid}">我的粉丝({$home_user['fans']})</a></legend>
            <div class="j_more"><a href="{u u/fans uid=$home_uid}">更多»</a></div>
        </fieldset>
        <div class="i_funs">
            <ul>
                <!--{loop $myfan_list $v}-->
                <li>
                    <a href="{u u/index uid=$v['uid']}" class="a1"><img src="{avatar $v['avatar'] m}" /></a>
                    <a href="{u u/index uid=$v['uid']}" class="a2">{$v['user_name']}</a>
                </li>
                <!--{/loop}-->
            </ul>
            <div class="g_clear"></div>
        </div>
    </div>

    <div id="myuserswrap" style="display:none;">
        <div class="i_tt">
            <h3>可能感兴趣的人</h3>
            <a href="javascript:;" onclick="getusers()" class="j_more">换一换</a>
        </div>
       
        <div class="i_warp">
            <div class="i_favlist">
                <ul id="myusers"></ul>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
function MeUpdateUserFollow2(obj,result) {
    var parent = $(obj).parent();
    if(result.status == 1) {
        parent.remove();
        $('#right_fnum').html(parseInt($('#right_fnum').html()) + 1);
        if($('#myusers').children().length == 0) {
            getusers();
        }
    } else {
        alert('关注失败，请重试！');
    }
}

function getusers() {
    $.get('/misc.php?action=getusers&homeuid={$home_uid}', function(s){
        if(s == '') {
            $('#myuserswrap').hide();
        } else {
            $('#myuserswrap').show();
            $('#myusers').html(s);
        }
    });
}

getusers();
</script>